package main

import (
	"fmt"
)

type person struct {
	name string
	age  uint
	addr address
}

type address struct {
	province string
	city     string
}

func (p person) String() string {
	return fmt.Sprintf("the name is %s,age is %d,%s!", p.name, p.age, p.addr)
}
func printString(s fmt.Stringer) {
	fmt.Println(s.String())
}
func NewPerson(name string) *person {
	return &person{name: name}
}
func main() {
	var p person
	fmt.Println(p)
	p1 := person{name: "zhangsan", age: 20, addr: address{province: "hb", city: "yuhua"}}

	fmt.Println(p1)
	fmt.Println(p1.name, p1.age)
	p2 := person{name: "lisi", age: 36, addr: address{province: "hb", city: "yuhua"}}
	fmt.Println(p2)
	printString(&p2)

	p3 := NewPerson("wangwu")
	printString(p3)
}
